import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

import VueLazyload from 'vue-lazyload'

import Vant from 'vant'
import 'vant/lib/index.css'

// 轮播图插件
import VueAwesomeSwiper from 'vue-awesome-swiper'
import 'swiper/dist/css/swiper.css'

import './assets/style/common.scss'
import './assets/style/common.css'

// import VConsole from 'vconsole'
// // eslint-disable-next-line no-new
// new VConsole()

Vue.use(Vant)
  .use(VueLazyload)
  .use(VueAwesomeSwiper)

Vue.config.productionTip = false

router.afterEach((to, from) => {
  document.title = to.meta.head.title || '' // title 更改
  document.body.className = to.meta.body || 'fff' // 动态改变 body class
})

router.beforeEach((to, from, next) => {
  // 微信分享携带的其他参数
  if (window.location.search) {
    window.location.href = window.location.origin + window.location.pathname + '#' + to.fullPath
  } else {
    // // 存储拓客ID
    // if (to.query.inviter_id) {
    //   store._mutations.memberInviterId[0]({ inviterId: to.query.inviter_id })
    // }
    next()
  }
})

/**
 * 提供给APP退出H5
 */
window.callH5Logout = () => {
  store.commit('memberLogout')
}

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
